/**
 * ReportGear(2011)
 */
package com.reportgear.report.model.script.function;

import net.abbp.core.util.NumberUtils;
import com.reportgear.report.model.script.function.Function.Type;

/**
 * 计算所有参数的和
 * 
 * @version 1.0 2011-4-10
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since ReportGear 1.0
 */
public class Sum extends AbstractFunction {

	@Override
	public Object exec(Object[] args) {
		double result = 0.0D;

		for (Object p : args) {
			result += NumberUtils.convertToDouble(p, 0);
		}

		return result;
	}

	@Override
	public Type getType() {
		return Type.MATH;
	}
}
